package com.fwtai.entity;

import com.fwtai.config.ConfigFile;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * 带搜索功能且支持排序的数据获取
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2020-07-10 10:53
 * @QQ号码 444141300
 * @Email service@dwlai.com
 * @官网 http://www.fwtai.com
*/
@ApiModel("列表数据搜索功能的分页参数且支持单字段排序")
public final class ReqPage{

  @ApiModelProperty(value = "当前页,默认值为1",required = true)
  private Integer current = 1;

  @ApiModelProperty(value = "每页大小,默认值为10,每页显示的数据量,最大不能超过"+ConfigFile.size_api_default,required = true)
  private Integer pageSize = 10;

  @ApiModelProperty(value = "排序关键字,升序ASC或降序DESC,结合column一起使用。不填时不排序",required = false)
  private String order;

  @ApiModelProperty(value = "排序字段|排序的列,结合order一起使用。不填时不排序",required = false)
  private String column;

  public Integer getCurrent(){
    if(current <= 0) return 1;
    return current;
  }

  public void setCurrent(final Integer current){
    if(current < 1){
      this.current = 1;
    }else{
      this.current = current;
    }
  }

  public Integer getPageSize(){
    return pageSize;
  }

  public void setPageSize(final Integer pageSize){
    if(pageSize < 1 || pageSize > ConfigFile.size_api_default){
      this.pageSize = 10;
    }else{
      this.pageSize = pageSize;
    }
  }

  public String getOrder(){
    return order;
  }

  public void setOrder(String order){
    this.order = order;
  }

  public String getColumn(){
    return column;
  }

  public void setColumn(String column){
    this.column = column;
  }
}